from common.base import Base,get_driver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from page.mylogin_page import MyLogin
from page.centrol_page import Centrol

class General1(Base):
    # 商品重量
    def goods_weight(self,weight=350):
        self.send_keys((By.NAME,'goods_weight'),weight)
    # 商品库存数量
    def goods_number(self,number=3000):
        num = self.driver.find_element_by_name('goods_number')
        num.clear()
        self.send_keys((By.NAME, 'goods_number'),number)
    # 警告库存数量
    def warn_number(self,number=10):
        num = self.driver.find_element_by_name('warn_number')
        num.clear()
        self.send_keys((By.NAME, 'warn_number'),number)
    # 关键词
    def keywords(self,content = '最新款平板电脑'):
        self.send_keys((By.NAME,'keywords'),content)
    # 简单描述信息
    def goods_brief(self,content = '屏幕大，照相好看，价格实惠，快来买'):
        self.send_keys((By.NAME, 'goods_brief'), content)
    # 确认按钮
    def confirm(self):
        self.click((By.XPATH, '//div[@class="button-div"]/input[2]'))


if __name__ == '__main__':
    driver=get_driver()
    driver.get('http://localhost:8080/ecshop/admin/privilege.php?act=login')
    c=Centrol(driver)
    general=General1(driver)
    m = MyLogin(driver)
    m.theclose()
    m.theclick()
    m.username()
    m.password()
    m.login()
    c.themain1()
    general.goods_weight()
    general.goods_number()
    general.warn_number()
    general.keywords()
    general.goods_brief()
